package com.heima.kafka.boot.listener;

import com.alibaba.fastjson.JSON;
import com.heima.kafka.boot.pojos.User;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class MessageListener {

    //订阅主题,并监听
    @KafkaListener(topics = {"boot-consumer-topic"})
    public void getMessage(ConsumerRecord consumerRecord){
        System.out.println("最终获取的结果："+consumerRecord.key()+":"+consumerRecord.value());
    }
}
